package Collections.methodTest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;

public class methodTest {
    public static void main(String[] args) {
        //弄个数组 然后打乱
        var numbers = new ArrayList<Integer>();
        for (int i = 1; i <= 6; i++) {
            numbers.add(i);
        }
        System.out.println("原数组:"+numbers);
        java.util.Collections.shuffle(numbers);
        System.out.println("打乱后的数组:"+numbers+"; by use (Collections.shuffle(numbers))");
        System.out.println("数组最小元素:"+java.util.Collections.min(numbers)+"; by use(Collections.min(numbers))");
        System.out.println("数组最大元素:"+java.util.Collections.max(numbers)+"; by use(Collections.max(numbers))");
        Collections.addAll(numbers,1314,520,520);
        System.out.println("添加元素:"+numbers+"; by use (Collections.addAll(numbers,1314,520,520);)");
        Collections.replaceAll(numbers,520,521);
        System.out.println("替换元素:"+numbers+"; by use (Collections.replaceAll(numbers,520,521);)");
        Collections.reverse(numbers);
        System.out.println("逆置列表中的元素顺序:"+numbers+";by use(Collections.reverse(numbers);)");
        numbers.removeIf(w ->w<509);
        System.out.println("移除符合条件的元素调用lambda:"+numbers+";by use(numbers.removeIf(w ->w<509);)");
    }
}
